local sk__jiaohui = fk.CreateSkill {

  name = "sk__jiaohui",

  tags = {  },

}



sk__jiaohui:addEffect(fk.DamageInflicted, {
  name = "sk__jiaohui",
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(sk__jiaohui.name)
  end,
  on_cost = function(self, event, target, player, data)
    local extra_data = {
      num = 1,
      min_num = 0,
      include_equip = true,
      skillName = sk__jiaohui.name,
      pattern = ".",
    }
    local success, dat = player.room:askForUseActiveSkill(player, "discard_skill", "#sk__jiaohui-invoke", true, extra_data)
    if success then
      event:setCostData(self, dat~=nil and dat.cards or {})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    if #event:getCostData(self) == 0 then
      player:drawCards(1, sk__jiaohui.name)
    else
      player.room:throwCard(event:getCostData(self), sk__jiaohui.name, player, player)
    end
    if player:getHandcardNum() == player.hp then
      data.damage = data.damage - 1
    end
  end,
})

return sk__jiaohui